Module modWRDBGraph
    Public Sub Main()
        System.Windows.Forms.Application.EnableVisualStyles()

        'set registry key for WASP (is also done in Innosetup script)
        My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\USEPA\WASP\7.0", "CbimePostProcessor", My.Application.Info.DirectoryPath & "\WRDBGraph.EXE")
        'My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\USEPA\WASP\8.0", "CbimePostProcessor", My.Application.Info.DirectoryPath & "\WRDBGraph.EXE")

        With New WRDB.Graph.clsGraph
            If My.Application.CommandLineArgs.Count = 0 Then
                .ShowGraph()
            Else
                Dim cmdLine As String = My.Application.CommandLineArgs(0).Replace("""", "")
                If cmdLine.ToUpper.Replace("/", "-") = "-L" Then
                    .iShowGraph(, , True)
                Else
                    Dim filename As String = cmdLine.Replace("""", "").Trim
                    Dim ext As String = IO.Path.GetExtension(filename)
                    'Select Case ext.ToUpper
                    '    Case ".GRAPH"
                    '        If My.Computer.FileSystem.FileExists(filename) Then .iShowGraph(, filename)
                    '    Case ".WIF", ".DB", ".BMD", ".CLF"
                    '        'starting from WASP, don't show error message
                    '        .ShowGraph()
                    '    Case Else
                    '        MessageBox.Show("WRDBGraph usage:\n\t-L or /L\t= load last graph\n\tFilename\t= load specified .graph, .bmd, etc., file on startup (enclose in quotes if path contains spaces)".Replace("\n", vbCr).Replace("\t", vbTab) & IIf(filename <> "", vbCr & vbCr & "The command line was: " & filename, ""), "WRDBGraph", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    'End Select
                    If My.Computer.FileSystem.FileExists(filename) Then
                        .iShowGraph(, filename)
                    Else
                        MessageBox.Show("WRDBGraph usage:\n\t-L or /L\t= load last graph\n\tFilename\t= load specified .graph, .bmd, etc., file on startup (enclose in quotes if path contains spaces)".Replace("\n", vbCr).Replace("\t", vbTab) & IIf(filename <> "", vbCr & vbCr & "The command line was: " & filename, ""), "WRDBGraph", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End If
                End If
            End If
        End With
    End Sub
End Module
